﻿using System;
using System.Xml;
using Soveryn.Commerce.BaseClasses;
using Soveryn.Commerce.Shared;
namespace Soveryn.Commerce.Doodads
{
    public partial class SubCategoryList : DoodadBaseClass
    {
        new protected void Page_Load(object sender, EventArgs e)
        {

            base.Page_Load(sender, e);

            if (IsPostBack)
                return;

            HTMLLiteral.Text = Properties.DoodadInstanceHTML;

            XmlNodeList nodes = ParentMasterPage.PageListXML.SelectNodes("//Page[ParentPageID='" + ParentPage.PageID + "']");
            foreach (XmlNode node in nodes)
            {
                PageProperties page = PageProperties.Create(node);
                if(!String.IsNullOrEmpty(page.CategoryID))
                    ListHTMLLiteral.Text += "<a href='" + page.SEO.GetURL(ParentPage) + "'>" + page.SEO.MenuLinkText + "</a>";
            }

            if (ParentPage.EditMode && ParentPage.EmployeeLoggedIn)
            {
                HTMLPanel.CssClass = "editable";
                HTMLPanel.Attributes.Add("data-id", Properties.ElementID);
            }

        }
    }
}